/********************************************/
  // Creation History
  // --------------------------------------------------------------
  //	Company:			HTHK
  //	NAME:				ProjectGroupSearch.java
  //    Title   :		find ProjectGroup Records, return one or more records
  //                         
  //	FUNCTION:			
  //	BY:				Poly Li
  //	DATE:				14-01-2004
  // --------------------------------------------------------------
/*********************************************/
// Copyright (c) 2002 HTHK

package tss.projectgroup;

import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
//import java.net.*;
//import java.util.*;
//import java.text.*;
import java.sql.*;

import com.ffpc.sql.*;
import com.ffpc.struts.StrutsMessage;

import tss.common.DBServlet2;

/**
 * A Class class.
 * <P>
 * @author HTHK
 */
public class ProjectGroupSearch
  extends DBServlet2 {

  @Override
protected String perform(  HttpServletRequest request,
                             HttpServletResponse response,
                             StrutsMessage message)
    throws  ServletException,
            IOException,
            SQLException,
            DataException,
            Exception
  {
      //New A Project Group
      ProjectGroupBean projectGroup = ProjectGroupProcess.createBean();

      //Get search condition
     projectGroup.setProject_name(request.getParameter("project_name"));
     projectGroup.setGroup_name(request.getParameter("group_name"));

	  //Get the results
      ProjectGroupBean[] projectGroups = ProjectGroupProcess.find(this.getConnection(),projectGroup);

      //Find nothing
      if (projectGroups==null || projectGroups.length==0 )
      {
          message.setMessage("No record, please input another criteria.");
          return "tss/projectgroup/ProjectGroupSearch.jsp";
      }
      //Find a record
      else if (projectGroups.length==1)
      {
          request.setAttribute("projectGroups",projectGroups[0]);
          return "tss/projectgroup/ProjectGroup.jsp?formAction=Update";
      }
      //find more than one records
      else
      {
          request.setAttribute("projectGroups",projectGroups);
          return "tss/projectgroup/ProjectGroupList.jsp";
      }
  }
}


